(async function () {
    function randomData() {
        return Math.round(Math.random() * 500);
    }

    var mydata = [{
            name: '北京',
            value: randomData()
        }, {
            name: '山东',
            value: 9999
        },
        {
            name: '上海',
            value: randomData()
        }, {
            name: '重庆',
            value: randomData()
        },
        {
            name: '河北',
            value: randomData()
        }, {
            name: '河南',
            value: randomData()
        },
        {
            name: '云南',
            value: randomData()
        }, {
            name: '辽宁',
            value: randomData()
        },
        {
            name: '黑龙江',
            value: randomData()
        }, {
            name: '湖南',
            value: randomData()
        },
        {
            name: '安徽',
            value: randomData()
        }, {
            name: '天津',
            value: randomData()
        },
        {
            name: '新疆',
            value: randomData()
        }, {
            name: '江苏',
            value: randomData()
        },
        {
            name: '浙江',
            value: randomData()
        }, {
            name: '江西',
            value: randomData()
        },
        {
            name: '湖北',
            value: randomData()
        }, {
            name: '广西',
            value: randomData()
        },
        {
            name: '甘肃',
            value: randomData()
        }, {
            name: '山西',
            value: randomData()
        },
        {
            name: '内蒙古',
            value: randomData()
        }, {
            name: '陕西',
            value: randomData()
        },
        {
            name: '吉林',
            value: randomData()
        }, {
            name: '福建',
            value: randomData()
        },
        {
            name: '贵州',
            value: randomData()
        }, {
            name: '广东',
            value: randomData()
        },
        {
            name: '青海',
            value: randomData()
        }, {
            name: '西藏',
            value: randomData()
        },
        {
            name: '四川',
            value: randomData()
        }, {
            name: '宁夏',
            value: randomData()
        },
        {
            name: '海南',
            value: randomData()
        }, {
            name: '台湾',
            value: randomData()
        },
        {
            name: '香港',
            value: randomData()
        }, {
            name: '澳门',
            value: randomData()
        }
    ];

    const myChart = echarts.init(document.getElementById("china_map"));
    // myChart.showLoading();
    const resp = await fetch('https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json').then((resp) => resp.json())
    console.log(mydata)

    echarts.registerMap('China', resp);
    myChart.setOption({
        title: {
            text: "注册用户分布图"
        },
        tooltip: {
            formatter: "{b} 注册用户 {c}人"
        },
        visualMap: {
            left: "left",
            top: "center",
            min: 0,
            max: 1000,
            text: ["高", "低"],
            calculable: true,
            inRange: {
                color: ["#E0FFFF", "#00BFFF"]
            }
        },
        series: [{
            name: '各省份的总成交量对比',
            type: 'map',
            mapType: 'china',
            roam: true,
            scaleLimit:{
                min: 0.7,
                max: 3
            },
            data: mydata
        }]

    })
    // myChart.hideLoading()
})()